package spring.core.aop.aspectj;

import spring.core.aop.DefaultTeacherService;
import spring.core.aop.TeacherService;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * @author 1203056
 * @version Id: AspectJAnnotationDemo.java, v 0.1 2021-09-07 10:53 1203056 Exp $
 */
@Configuration
@EnableAspectJAutoProxy
public class AspectJAnnotationDemo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(AspectJAnnotationDemo.class,TeacherAspect.class,RootAspect.class);
        context.registerBean("teacher", DefaultTeacherService.class);
        context.refresh();

        TeacherService teacherService =  context.getBean(TeacherService.class);
        teacherService.teach("历史");
//        System.out.println(teacherService.getClass());
        System.out.println(teacherService.toString());
    }
}
